﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace MyFace
{
    class Peca
    {
        Texture2D Textura;
        Vector2 Posicao;
        Rectangle Retangulo;
        string TexturaPeca;

        float Escala = 0.5f;

        int Altura, Largura;

        public Peca(Vector2 posicao, Rectangle retangulo, string nomeTexturaPeca)
        {
            Posicao = posicao;
            Retangulo = retangulo;
            TexturaPeca = nomeTexturaPeca;
        }

        public void Load(ContentManager Content)
        {
            Textura = Content.Load<Texture2D>(TexturaPeca);
        }

        public void Update(GameTime gameTime)
        {
            Retangulo = new Rectangle((int)Posicao.X, (int)Posicao.Y, Retangulo.Width, Retangulo.Height);
            //Largura = Convert.ToInt16(Retangulo.Width * Escala);
            // Altura = Convert.ToInt16(Retangulo.Height * Escala);
            if (Retangulo.Contains(Cursor.X, Cursor.Y))
            {
                if (Cursor.mstate.LeftButton == ButtonState.Pressed)
                {
                    Posicao.X += Cursor.mstate.X - Cursor.mstateold.X;
                    Posicao.Y += Cursor.mstate.Y - Cursor.mstateold.Y;
                }
            }
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Textura, Retangulo, Color.White);
            
        }
    }
}
